import {
	http,
	Method
} from "@/utils/request.js";

// 润色微信登录
export function runLogin(payload) {
	return http.request({
		url: `/auth/wechat/login`,
		method: Method.POST,
		data: payload
	});
}
// 润色微信注册
export function runRegister(payload) {
	return http.request({
		url: `/auth/wechat/register`,
		method: Method.POST,
		data: payload
	});
}

// 润色微信注册
export function updateUser(payload) {
	return http.request({
		url: `/user/updateUser`,
		method: Method.POST,
		data: payload
	});
}

// 获取好友双方房间内的所有消息
export function getRoomMessage(payload) {
	return http.request({
		url: `/user/room/messages`,
		method: Method.GET,
		data: payload
	});
}

// 获取用户好友
export function getUserFriends(payload) {
	return http.request({
		url: `/user/friends`,
		method: Method.GET,
		data: payload
	});
}


// 接受好友邀请
export function acceptInvite(payload) {
	return http.request({
		url: `/user/accept`,
		method: Method.GET,
		data: payload
	});
}




// 根据userid获取用户信息
export function getUserInfo(payload) {
	return http.request({
		url: `/user`,
		method: Method.GET,
		data: payload
	});
}

/**
 * 微信登录
 */
export function autoLogin(payload) {
	return http.request({
		url: `/user/wechatLogin`,
		method: Method.POST,
		data: payload
	});
}




/**
 * 微信注册
 */
export function wechatRegister(payload) {
	console.log("传递的数据是", payload);
	return http.request({
		url: `/user/wechatRegister`,
		method: Method.POST,
		data: payload
	});
}

/**
 * 获取微信手机号
 */
export function wechatMobile(payload) {
	return http.request({
		url: `/user/getWechatMobile`,
		method: Method.POST,
		data: payload
	});
}


/**
 *  测试获取用户信息
 */
export function testGetUserInfo() {
	return http.request({
		url: `/user/info`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *  更新用户信息
 */
export function updateUserInfo(payload) {
	return http.request({
		url: `/user/update`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}

/**
 *  获取朋友列表
 */
export function getFriendList() {
	return http.request({
		url: `/friendRelationship/myFriendList`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *  获取朋友列表
 */
export function getFriendGropList() {
	return http.request({
		url: `/friendRelationship/myFriendGroupList`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *  获取朋友列表
 */
export function getUserDevice() {
	return http.request({
		url: `/device/getUserBindDevices`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *   修改朋友备注
 */
export function updateFirendRemark(payload) {
	return http.request({
		url: `/friendRelationship/updateRemark`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}
/**
 *   切换设备
 */
export function changeDeviceLogin(deviceId) {
	return http.request({
		url: `/device/cutLoginDevice/${deviceId}`,
		method: Method.GET,
		needToken: true,

	});
}


/**
 *   置顶分组
 */
export function toTopGroup(id) {
	return http.request({
		url: `/friendRelationship/topGroup/${id}`,
		method: Method.GET,
		needToken: true,

	});
}
/**
 *   删除好友
 */
export function deleteFirendById(id) {
	return http.request({
		url: `/friendRelationship/delete/${id}`,
		method: Method.DELETE,
		needToken: true,

	});
}
/**
 *   获取分组详情
 */
export function getFirendGroupDetail(id) {
	return http.request({
		url: `/friendRelationship/friendGroupInfo/${id}`,
		method: Method.GET,
		needToken: true,

	});
}
/**
 *   删除分组中的好友
 */
export function deleteGroupFriends(payload) {
	return http.request({
		url: `/friendRelationship/deleteGroupFriend`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}


/**
 *   获取设备详情
 */
export function getNowDeviceInfo() {
	return http.request({
		url: `/device/getDevicesInfo`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *   修改设备
 */
export function deviceUpdate(payload) {
	return http.request({
		url: `/device/update`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}





/**
 *   修改分组名称
 */
export function updateGroupName(payload) {
	return http.request({
		url: `/friendRelationship/updateGroup`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}


/**
 *   解散群组
 */
export function deleteFirendGroupById(id) {
	return http.request({
		url: `/friendRelationship/deleteGroup/${id}`,
		method: Method.DELETE,
		needToken: true,

	});
}




/**
 *   添加好友到分组
 */
export function addFirendToGroup(payload) {
	return http.request({
		url: `/friendRelationship/createFriendToGroup`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}



/**
 *   删除分组中的好友
 */
export function deleteGroupFriend(payload) {
	return http.request({
		url: `/friendRelationship/deleteGroupFriend`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}



/**
 *   创建分组
 */
export function createFirendGroup(payload) {
	return http.request({
		url: `/friendRelationship/createGroup`,
		method: Method.POST,
		needToken: true,
		data: payload
	});
}

// 设备相关

/**
 *   获取微信绑定设备验证码
 */
export function getWeChatBindDeviceCode(deviceId) {
	return http.request({
		url: `/device/getWeChatBindDeviceCode/${deviceId}`,
		method: Method.GET,
		needToken: true,
	});
}


/**
 *   微信绑定设备
 */
export function wechatBindDevice(deviceId) {
	return http.request({
		url: `/device/wechatBind/${deviceId}`,
		method: Method.GET,
		needToken: true,
		// data: payload
	});
}